package com.liao.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.liao.dao.TeacherDao;
import com.liao.entity.Teacher;
import com.liao.util.Result;
@RestController
public class TeacherController {
	@Autowired
	TeacherDao te;
    @RequestMapping("/getAllTe")
    public Object getllTe(@RequestParam Map<String, Object> map) {
    	 Integer page = Integer.parseInt(map.get("page").toString());
  		Integer limit = Integer.parseInt(map.get("limit").toString());
  		
  		map.put("page", (page - 1) * limit);
  		map.put("limit", limit);
  		List<Map<String, Object>> stduent = te.getAllTe(map);

  		int count = te.getCount();// 获取总条数
  		Result res = new Result("0", "true", count, stduent);
  		return res;	 
    }
    @RequestMapping("/tinserts")
    public Object inserts(@RequestParam Map<String, Object> map) {
   	 Result res =new Result("0","true",te.tinserts(map),"添加成功");
   	 return res;    
    }
    @RequestMapping("/tupdate")
    public Object update(@RequestParam Map<String, Object> map) {
   	 Result res =new Result("0","true",te.tupdate(map),"修改成功");
   	 return res; 
    }
    @RequestMapping("/tdel")
    public Object del(int id) {
   	 Result res =new Result("0","true",te.tdeletes(id),"删除成功");
   	 return res; 
    }
}
